home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / hd-install / thor.lha / rexx / KeepMsg.thor < prev    next >
Text File  |  1997-04-27  |  5KB  |  162 lines

  1. /*
  2. ** $VER: KeepMsg.thor 1.3c (23.4.97)
  3. ** by Eirik Nicolai Synnes <eirikns@sn.no>
  4. **
  5. ** Copies the current or selected message to a special "Keep" conference and
  6. ** sets the KEEP flag on them.
  7. **
  8. ** Specify the conference name in the toconf string below. If the conference
  9. ** doesn't exist it will be created.
  10. **
  11. ** If you don't want the copy in the destination conference to be marked as
  12. ** unread make sure nomarkmsg is set to 1 below. Otherwise set it to 0.
  13. **
  14. ** Fixed in 1.3c:
  15. ** o Added support for "real kills"
  16. */
  17.  
  18. toconf  = 'The Keep'
  19. nomarkmsg = 0
  20.  
  21. options results
  22. options failat 30
  23.  
  24. signal on syntax
  25. signal on halt
  26. signal on break_c
  27.  
  28. CDF_NOT_ON_BBS   = '00008000'x  /* This conference is not on the bbs. */
  29.  
  30. /* Open Thor and BBSREAD ARexx ports' */
  31.  
  32. p=' '||address()||' '||show('P',,)
  33. if pos(' THOR.',p)>0 then thorport=word(substr(p,pos(' THOR.',p)+1),1)
  34. else do
  35.     say 'No THOR port found!'
  36.     exit(0)
  37.     end
  38.  
  39. if ~show('p', 'BBSREAD') then do
  40.     address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  41.     "WaitForPort BBSREAD"
  42.     if rc ~= 0 then do
  43.         address(thorport)
  44.         REQUESTNOTIFY '"Couldn''t open BBSRead''s ARexx port."' '"I see"'
  45.         exit(0)
  46.         end
  47.     end
  48.  
  49. address(thorport)
  50. trace off; CURRENTMSG curmsg; trace on
  51. if rc ~= 0 then do
  52.     REQUESTNOTIFY '"CURRENTMSG:\n'THOR.LASTERROR'"' '"Abort"'
  53.     exit(0)
  54.     end
  55.  
  56. GETMSGLISTSELECTED msgsel
  57. if rc = 3 | rc = 5 then do
  58.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  59.     end
  60. else if rc ~= 0 then do
  61.     REQUESTNOTIFY '"GETMSGLISTSELECTED:\n'THOR.LASTERROR'"' '"Abort"'
  62.     exit(0)
  63.     end
  64.  
  65. if msgsel.COUNT = 0 then do
  66.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  67.     end
  68.  
  69. address(bbsread)
  70. BUFMODE COPYBACK
  71.  
  72. do i = 1 to msgsel.COUNT
  73.     drop data. head. text.
  74.  
  75.     address(bbsread)
  76.     READBRMESSAGE '"'curmsg.BBSNAME'"' '"'curmsg.CONFNAME'"' '"'msgsel.i'"' TEXTSTEM text HEADSTEM head DATASTEM data
  77.     if rc ~= 0 then do
  78.         address(thorport)
  79.         REQUESTNOTIFY '"READBRMESSAGE (message #'msgsel.i'):\n 'BBSREAD.LASTERROR'"' '"Abort"'
  80.         signal cleanup
  81.         end
  82.  
  83.     if text.TEXT.COUNT = 0 & (text.PART.COUNT = 0 | symbol('text.PART.COUNT') ~= 'VAR') then do
  84.         address(thorport)
  85.         REQUESTNOTIFY '"No message body (message #'msgsel.i').\nMessage not copied."' '"'_Ok'"'
  86.         signal cleanup
  87.         end
  88.  
  89.     text.replyconf = curmsg.CONFNAME
  90.  
  91.     if head.fromname        ~= "HEAD.FROMNAME"        then text.fromname        = head.fromname
  92.     if head.fromaddr        ~= "HEAD.FROMADDR"        then text.fromaddr        = head.fromaddr
  93.     if head.toname          ~= "HEAD.TONAME"          then text.toname          = head.toname
  94.     if head.toaddr          ~= "HEAD.TOADDR"          then text.toaddr          = head.toaddr
  95.     if head.msgid           ~= "HEAD.MSGID"           then text.msgid           = head.msgid
  96.     if head.refid           ~= "HEAD.REFID"           then text.refid           = head.refid
  97.     if head.creationdate    ~= "HEAD.CREATIONDATE"    then text.creationdate    = head.creationdate
  98.     if head.creationdatetxt ~= "HEAD.CREATIONDATETXT" then text.creationdatetxt = head.creationdatetxt
  99.     if head.subject         ~= "HEAD.SUBJECT"         then text.subject         = head.subject
  100.  
  101.     red = ""; priv = ""; urg = ""; imp = ""; conf = ""
  102.     if bittst(data.flags, 0)  then red  = "READ"
  103.     if bittst(data.flags, 2)  then priv = "PRIVATE"
  104.     if bittst(data.flags, 11) then urg  = "URGENT"
  105.     if bittst(data.flags, 12) then imp  = "IMPORTANT"
  106.     if bittst(data.flags, 17) then conf = "CONFIDENTIAL"
  107.  
  108.     if nomarkmsg then nomark = 'DONTMARKMESSAGE'
  109.     else nomark = ''
  110.  
  111.     WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  112.     if rc = 7 then do
  113.         CONFIGCONF '"'curmsg.BBSNAME'"' '"'toconf'"' SET c2x(CDF_NOT_ON_BBS)
  114.         WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  115.         if rc ~= 0 then do
  116.             address(thorport)
  117.             REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  118.             signal cleanup
  119.             end
  120.         end
  121.     else if rc ~= 0 then do
  122.         address(thorport)
  123.         REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  124.         signal cleanup
  125.         end
  126.  
  127.     mnr = result
  128.     repl = ""
  129.     if bittst(data.flags, 1) then repl = "SETREPLIED"
  130.  
  131.     if mnr = -1 then do
  132.         REQUESTNOTIFY '"The message could not be written\nbecause it was caught by a kill entry."' '"_Ok"'
  133.         signal cleanup
  134.         end
  135.  
  136.     address(bbsread)
  137.     UPDATEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' mnr SETKEEP repl HAZELEVEL data.HAZELEVEL
  138.     if rc ~= 0 then do
  139.         address(thorport)
  140.         REQUESTNOTIFY '"UPDATEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  141.         signal cleanup
  142.         end
  143.     end
  144.  
  145. address(thorport)
  146. UPDATECONFWINDOW
  147.  
  148. signal cleanup
  149.  
  150. error:
  151. halt:
  152. break_c:
  153.  
  154. if rc ~= 0 then say '+++ Line 'sigl' returned 'rc': 'errortext(rc)
  155.  
  156. cleanup:
  157.  
  158. address(bbsread)
  159. BUFMODE ENDCOPYBACK
  160.  
  161. exit(0)
  162.